package com.pacific.sign.biz.service;

import com.pacific.common.request.CommonRequest;
import com.pacific.common.response.CommonResponse;
import com.pacific.sign.biz.service.impl.MenuService;
import com.pacific.sign.biz.wrapper.CommonWrapper;
import com.pacific.sign.biz.wrapper.aop.LogAnnotation;
import com.pacific.sign.model.po.pac.mbg.PacHcMenu;
import com.pacific.sign.model.po.pac.request.PacHcMenuQueryRequest;
import com.pacific.sign.model.po.pac.request.PacHcMenuRequest;
import com.pacific.sign.model.po.pac.response.PacHcMenuQueryResponse;
import com.pacific.sign.model.po.pac.response.PacHcMenuResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 1 on 2017/6/28.
 */
@Service
public class HcMenuServiceImpl extends CommonWrapper implements HcMenuService {
    @Autowired
    private MenuService menuService;

    @LogAnnotation("菜单新增")
    public CommonResponse<Integer> insert(CommonRequest<PacHcMenu> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(menuService.insert(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("菜单更新")
    public CommonResponse<Integer> update(CommonRequest<PacHcMenu> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(menuService.update(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("菜单id查询")
    public CommonResponse<PacHcMenu> queryById(CommonRequest<Integer> request) {
        CommonResponse<PacHcMenu> response = new CommonResponse<PacHcMenu>();
        try {
            response.setResult(menuService.selectById(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("菜单删除")
    public CommonResponse<Integer> delete(CommonRequest<PacHcMenu> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(menuService.delete(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("菜单查询")
    public CommonResponse<PacHcMenuQueryResponse> query(CommonRequest<PacHcMenuQueryRequest> request) {
        CommonResponse<PacHcMenuQueryResponse> response = new CommonResponse<PacHcMenuQueryResponse>();
        try {
            response.setResult(menuService.query(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("菜单加载...")
    public CommonResponse<PacHcMenuResponse> queryMenu(CommonRequest<PacHcMenuRequest> request) {
        CommonResponse<PacHcMenuResponse> response = new CommonResponse<PacHcMenuResponse>();
        try {
            response.setResult(menuService.queryMenu(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }
}
